import React from 'react';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import {
  Card,
  Button,
  Row,
  Col,
  Modal,
  Form,
  Checkbox,
  Tabs,
  Space,
  notification,
  Select,
  DatePicker,
  Input,
  Radio,
  Dropdown,
  InputNumber,
  message,
  Menu,
} from 'antd';
import {
  PlusOutlined,
  CloseOutlined,
  RightOutlined,
  DownOutlined,
  ExclamationCircleOutlined,
} from '@ant-design/icons';
import JobTree from './jobTree';
import { connect } from 'umi';
import * as Request from '@/services/Request';
import moment from 'moment';
import {
  ResourceGrpSelect,
  OpMasterSelect,
  ResourceSelect,
  EmpSelect,
} from '@/components/FormItemSelect';
import PartSelect from '@/components/PartSelect';
import JobSelect from '@/components/JobSelect';

const { TabPane } = Tabs;
const { confirm } = Modal;
const apiURL = '/api/services/app/JobHead/';
const apiURLAsm = '/api/services/app/JobAsmbl/';
const apiURLMtl = '/api/services/app/JobMtl/';
const apiURLOper = '/api/services/app/JobOper/';
class ViewPage extends React.Component<any, any> {
  constructor(props: any) {
    super(props);
    this.state = {
      loading: false,
      visible: false,
      dataSource: [],
      JobHead: { jobNum: '0' },
      JobAsmbl: {},
      JobMtl: {},
      JobOper: {},
      defTab: '1',
    };
  }
  formRef: any = React.createRef();
  onFinish = (values: any) => {
    var JobHead = values.JobHead;
    var JobMtl = values.JobMtl;
    var JobAsmbl = values.JobAsmbl;
    var JobOper = values.JobOper;
    var data = { jobNum: '0' };
    if (JobHead) {
      this.saveJobHead(JobHead);
      data.jobNum = JobHead.jobNum;
    }
    if (JobAsmbl) {
      this.saveJobData(JobAsmbl, apiURLAsm);
      data.jobNum = JobAsmbl.jobNum;
    }
    if (JobMtl) {
      this.saveJobData(JobMtl, apiURLMtl);
      data.jobNum = JobMtl.jobNum;
    }
    if (JobOper) {
      JobOper.opDesc = JobOper.opCode.label;
      JobOper.opCode = JobOper.opCode.value;
      this.saveJobData(JobOper, apiURLOper);
      data.jobNum = JobOper.jobNum;
    }
    this.getObj(data);
  };
  saveJobHead = (JobHead: any) => {
    JobHead.dueDate = JobHead.dueDate?.format('YYYY-MM-DD');
    JobHead.startDate = JobHead.startDate?.format('YYYY-MM-DD');
    var act = 'New';
    var method = 'POST';
    if (JobHead.id) {
      act = 'Update';
      method = 'PUT';
    }
    Request.post(apiURL + act, JobHead, method).then((response) => {
      if (response) {
        if (response.success) {
          message.success('保存成功！');
          this.getObj(JobHead.jobNum);
        } else {
          notification.error({
            message: response.error.message,
            description: response.error.details,
          });
        }
        this.setState({ loading: false });
      }
    });
  };
  saveJobData = (data: any, api: string) => {
    var act = 'New';
    var method = 'POST';
    if (data.id) {
      act = 'Update';
      method = 'PUT';
    }
    Request.post(api + act, data, method).then((response) => {
      if (response) {
        if (response.success) {
          message.success('保存成功！');
          this.getObj(data.jobNum);
        } else {
          notification.error({
            message: response.error.message,
            description: response.error.details,
          });
        }
        this.setState({ loading: false });
      }
    });
  };
  bomTree: any = JobTree;
  onRef = (ref: any) => {
    this.bomTree = ref;
  };
  setCurrent = (part?: any) => {
    var JobHead: any = {};
    JobHead.partNum = part.partNum;
    JobHead.partDescription = part.partDescription;
    JobHead.ium = part.ium;
    this.formRef.current.setFieldsValue({ JobHead });
    this.setState({ partRevs: part.revs });
  };
  setCurrent2 = (part?: any) => {
    var JobMtl: any = {};
    JobMtl.partNum = part.partNum;
    JobMtl.partDescription = part.partDescription;
    JobMtl.ium = part.ium;
    this.formRef.current.setFieldsValue({ JobMtl });
  };
  setCurrent3 = (part?: any) => {
    var JobAsmbl: any = {};
    JobAsmbl.partNum = part.partNum;
    JobAsmbl.partDescription = part.partDescription;
    JobAsmbl.ium = part.ium;
    this.formRef.current.setFieldsValue({ JobAsmbl });
    this.setState({ partRevs2: part.revs });
  };
  getObj = (e: any) => {
    if (e.jobNum) {
      this.setState({ loading: true });
      Request.get(apiURL + 'GetJob?jobNum=' + e.jobNum).then((response) => {
        if (response) {
          if (response.success) {
            if (response.result.node) {
              var BomData = response.result;
              var JobHead = response.result.node;
              if (JobHead.dueDate) JobHead.dueDate = moment(JobHead.dueDate);
              this.setState({ BomData });
              if (BomData.childs[0]) {
                var JobAsmbl = BomData.childs[0];
                this.setCurrentAsmb(JobAsmbl, 'asm');
                if (JobAsmbl.boos[0]) {
                  var JobOper = JobAsmbl.boos[0];
                  this.setCurrentAsmb(JobOper.node, 'boo');
                  if (JobOper.mtls[0]) {
                    var JobMtl = JobOper.mtls[0];
                    this.setCurrentAsmb(JobMtl, 'mtl');
                  }
                }
              }
              this.setCurrentAsmb(JobHead, 'root');
              this.bomTree.fetchData(BomData);
            } else {
              message.error(e.jobNum + '不存在');
            }
          } else {
            message.error(response.error.message);
          }
          this.setState({ loading: false });
        }
      });
    }
  };
  fetchBom = () => {
    const { JobHead } = this.state;
    this.setState({ loading2: true });
    Request.post(
      apiURL +
        'FetchBom?jobNum=' +
        JobHead.jobNum +
        '&partNum=' +
        JobHead.partNum +
        '&revNum=' +
        JobHead.revisionNum,
    ).then((response) => {
      console.log(response);
      if (response.success) {
        this.getObj(JobHead.jobNum);
      } else {
        notification.error({
          message: response.error.message,
          description: response.error.details,
        });
      }
      this.setState({ loading2: false });
    });
  };
  setCurrentAsmb = (item: any, type: string) => {
    if (type == 'mtl') {
      this.setState({ JobMtl: item, defTab: '2' });
      this.formRef.current.setFieldsValue({ JobMtl: item });
    } else if (type == 'asm') {
      this.setState({ JobAsmbl: item.node, booList: item.boos, defTab: '3' });
      this.formRef.current.setFieldsValue({ JobAsmbl: item.node });
    } else if (type == 'boo') {
      this.setState({ JobOper: item, defTab: '4' });
      item.opCode = {
        key: item.opCode,
        value: item.opCode,
        label: item.opDesc,
      };
      this.formRef.current.setFieldsValue({ JobOper: item });
    } else {
      this.setState({ JobHead: item, defTab: '1' });
      this.formRef.current.setFieldsValue({ JobHead: item });
    }
  };
  tabSwitch = (key: any) => {
    this.setState({ defTab: key });
  };
  selectOpr = (e: any) => {
    var obj = this.state.booList.filter((o: any) => o.node.oprSeq == e)[0];
    if (obj) {
      let JobMtl: any = {};
      JobMtl.relatedOpRev = obj.node.revisionNum;
      this.formRef.current.setFieldsValue({ JobMtl });
    }
  };
  handleMenuClick = (e: any) => {
    const { JobHead, JobAsmbl } = this.state;
    if (e.key === '1') {
      this.formRef.current.resetFields();
      this.setState({ BomData: [] });
      this.bomTree.clearData();
    } else if (e.key === '2') {
      console.log(JobAsmbl);
      if (!JobAsmbl.id) {
        message.warning('请先选择半成品');
        return;
      }
      this.formRef.current.setFieldsValue({ JobMtl: null });
      let JobMtl = {
        jobNum: JobHead.jobNum,
        assemblySeq: JobAsmbl.assemblySeq,
      };
      this.formRef.current.setFieldsValue({ JobMtl });
    } else if (e.key === '3') {
      if (!JobAsmbl.id) {
        message.warning('请先选择上级半成品');
        return;
      }
      this.formRef.current.setFieldsValue({ JobAsmbl: null });
      let _JobAsmbl = {
        jobNum: JobHead.jobNum,
        parent: JobAsmbl.partNum,
      };
      this.formRef.current.setFieldsValue({ JobAsmbl: _JobAsmbl });
    } else {
      if (!JobAsmbl.id) {
        message.warning('请先选择半成品');
        return;
      }
      this.formRef.current.setFieldsValue({ JobOper: null });
      let _JobOper = {
        jobNum: JobHead.jobNum,
        assemblySeq: JobAsmbl.assemblySeq,
        partNum: JobAsmbl.partNum,
        partDescription: JobAsmbl.partDescription,
        revisionNum: JobAsmbl.revisionNum,
      };
      this.formRef.current.setFieldsValue({ JobOper: _JobOper });
    }
    this.setState({ defTab: e.key });
  };
  delObj = () => {
    const { defTab, JobAsmbl, JobOper, JobMtl, JobHead } = this.state;
    let ctrl = 'PartBom';
    let id = 0;
    if (defTab == '2') {
      ctrl = 'JobMtl';
      id = JobMtl.id;
    } else if (defTab == '3') {
      ctrl = 'JobAsmbl';
      id = JobAsmbl.id;
    } else if (defTab == '4') {
      ctrl = 'JobOper';
      id = JobOper.id;
    } else {
      ctrl = 'JobHead';
      id = JobHead.id;
    }
    let _this = this;
    confirm({
      title: '警告',
      icon: <ExclamationCircleOutlined />,
      content: '删除后将不可恢复，确定删除？',
      onOk() {
        _this.props
          .dispatch({
            type: 'Abp/delete',
            payload: { id },
            control: ctrl,
          })
          .then(() => {
            _this.getObj(JobHead.jobNum);
          });
      },
    });
  };
  render() {
    const layout = {
      labelCol: { span: 5 },
      wrapperCol: { span: 19 },
    };
    const { BomData, defTab, loading, loading2, booList, JobHead } = this.state;

    const selectRev = (
      <Select placeholder="选择版本">
        {this.state.partRevs?.map((item: any) => {
          return (
            <Select.Option key={item} value={item}>
              {item}
            </Select.Option>
          );
        })}
      </Select>
    );
    const selectRev2 = (
      <Select placeholder="选择版本">
        {this.state.partRevs2?.map((item: any) => {
          return (
            <Select.Option key={item} value={item}>
              {item}
            </Select.Option>
          );
        })}
      </Select>
    );
    return (
      <PageHeaderWrapper>
        <Form {...layout} ref={this.formRef} onFinish={this.onFinish}>
          <Row gutter={[16, 16]}>
            <Col span={6}>
              <JobTree onRef={this.onRef} BomData={BomData} setCurrentAsmb={this.setCurrentAsmb} />
            </Col>
            <Col span={18}>
              <Card
                title="工单明细"
                loading={loading}
                extra={
                  <Space>
                    {/* <Button key="1" type="primary" icon={<PlusOutlined />} onClick={this.newObj}>新建</Button> */}
                    <Dropdown
                      overlay={
                        <Menu onClick={this.handleMenuClick}>
                          <Menu.Item key="1" icon={<RightOutlined />}>
                            新建工单
                          </Menu.Item>
                          <Menu.Item
                            key="2"
                            icon={<RightOutlined />}
                            disabled={JobHead.jobNum === '0'}
                          >
                            新建物料
                          </Menu.Item>
                          <Menu.Item
                            key="3"
                            icon={<RightOutlined />}
                            disabled={JobHead.jobNum === '0'}
                          >
                            新建半成品
                          </Menu.Item>
                          <Menu.Item
                            key="4"
                            icon={<RightOutlined />}
                            disabled={JobHead.jobNum === '0'}
                          >
                            新建工序
                          </Menu.Item>
                        </Menu>
                      }
                    >
                      <Button type="primary" icon={<PlusOutlined />}>
                        新建 <DownOutlined />
                      </Button>
                    </Dropdown>
                    <Button key="2" type="primary" loading={loading} htmlType="submit">
                      保存
                    </Button>
                    <Button key="3" type="primary" onClick={this.fetchBom} loading={loading2}>
                      提取BOM
                    </Button>
                    <Button
                      key="4"
                      type="dashed"
                      danger
                      icon={<CloseOutlined />}
                      onClick={this.delObj}
                    >
                      删除
                    </Button>
                  </Space>
                }
              >
                <Tabs defaultActiveKey={defTab} activeKey={defTab} onChange={this.tabSwitch}>
                  <TabPane tab="工单" key="1">
                    <Row>
                      <Col span={12}>
                        <Form.Item name={['JobHead', 'id']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item label="工单号">
                          <Input.Group compact>
                            <JobSelect
                              width={200}
                              noStyle
                              name={['JobHead', 'jobNum']}
                              rules={[{ required: true, message: '工单号必填' }]}
                              setCurrent={this.getObj}
                            />
                          </Input.Group>
                        </Form.Item>
                        <Form.Item label="物料">
                          <Input.Group compact>
                            <PartSelect
                              name={['JobHead', 'partNum']}
                              noStyle
                              width={120}
                              required={true}
                              placeholder="物料编码"
                              setCurrent={this.setCurrent}
                              pType="M"
                            />
                            <Form.Item noStyle name={['JobHead', 'revisionNum']}>
                              {selectRev}
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item name={['JobHead', 'partDescription']} label="描述">
                          <Input disabled />
                        </Form.Item>
                        <EmpSelect
                          showSearch
                          width={200}
                          name={['JobHead', 'personID']}
                          label="计划员"
                        />
                        <Form.Item
                          name={['JobHead', 'jobType']}
                          label="工单类型"
                          rules={[{ required: true, message: '工单类型必填' }]}
                        >
                          <Select style={{ width: 200 }} placeholder="请选择工单类型">
                            <Select.Option value="MTO">订单生产</Select.Option>
                            <Select.Option value="MTS">库存生产</Select.Option>
                            <Select.Option value="MTJ">子工单</Select.Option>
                          </Select>
                        </Form.Item>
                      </Col>
                      <Col span={12}>
                        <Form.Item style={{ marginBottom: 0 }} wrapperCol={{ offset: 5 }}>
                          <Input.Group compact>
                            <Form.Item name={['JobHead', 'jobFirm']} valuePropName="checked">
                              <Checkbox>已确认</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobHead', 'jobClosed']} valuePropName="checked">
                              <Checkbox disabled>已完结</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobHead', 'jobCompleted']} valuePropName="checked">
                              <Checkbox>已完成</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobHead', 'jobReleased']} valuePropName="checked">
                              <Checkbox>已发放</Checkbox>
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item
                          name={['JobHead', 'dueDate']}
                          label="需求日期"
                          rules={[{ required: true, message: '请选择订单日期' }]}
                        >
                          <DatePicker />
                        </Form.Item>
                        <Form.Item label="生产数量">
                          <Input.Group compact>
                            <Form.Item
                              noStyle
                              name={['JobHead', 'prodQty']}
                              rules={[{ required: true, message: '生产数量必填' }]}
                            >
                              <InputNumber min={1} />
                            </Form.Item>
                            <Form.Item
                              noStyle
                              name={['JobHead', 'ium']}
                              rules={[{ required: true, message: '单位必填' }]}
                            >
                              <Input disabled style={{ width: 80 }} placeholder="IUM" />
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                      </Col>
                    </Row>
                  </TabPane>
                  <TabPane tab="物料" key="2">
                    <Row>
                      <Col span={12}>
                        <Form.Item name={['JobMtl', 'id']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobMtl', 'jobNum']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobMtl', 'assemblySeq']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobMtl', 'mtlSeq']} label="物料序号">
                          <InputNumber min={1} step={1} />
                        </Form.Item>
                        <Form.Item label="物料编码">
                          <Input.Group compact>
                            <PartSelect
                              name={['JobMtl', 'partNum']}
                              noStyle
                              width={120}
                              required={true}
                              placeholder="物料编码"
                              setCurrent={this.setCurrent2}
                              pType="P"
                            />
                          </Input.Group>
                        </Form.Item>
                        <Form.Item name={['JobMtl', 'partDescription']} label="描述">
                          <Input disabled />
                        </Form.Item>
                        <Form.Item style={{ marginBottom: 0 }} label="相关工序">
                          <Input.Group compact>
                            <Form.Item name={['JobMtl', 'relatedOperation']}>
                              <Select style={{ width: 200 }} onChange={this.selectOpr}>
                                {booList?.map((item: any) => {
                                  return (
                                    <Select.Option value={item.node.oprSeq} key={item.node.id}>
                                      {item.node.oprSeq} - {item.node.opDesc}
                                    </Select.Option>
                                  );
                                })}
                              </Select>
                            </Form.Item>
                            <Form.Item name={['JobMtl', 'relatedOpRev']}>
                              <Input placeholder="工序版本" style={{ width: 50 }} />
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item label="数量/父项" style={{ marginBottom: 0 }}>
                          <Input.Group compact>
                            <Form.Item
                              name={['JobMtl', 'qtyPer']}
                              rules={[{ required: true, message: '需求数量必填' }]}
                            >
                              <InputNumber min={1} style={{ width: 120, marginRight: 10 }} />
                            </Form.Item>
                            <Form.Item name={['JobMtl', 'fixedQty']} valuePropName="checked">
                              <Checkbox>固定数量</Checkbox>
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item label="需求数量">
                          <Input.Group compact>
                            <Form.Item
                              noStyle
                              name={['JobMtl', 'requiredQty']}
                              rules={[{ required: true, message: '需求数量必填' }]}
                            >
                              <InputNumber min={1} />
                            </Form.Item>
                            <Form.Item
                              noStyle
                              name={['JobMtl', 'ium']}
                              rules={[{ required: true, message: '单位必填' }]}
                            >
                              <Input disabled style={{ width: 70 }} placeholder="单位" />
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item style={{ marginBottom: 0 }} wrapperCol={{ offset: 5 }}>
                          <Input.Group compact>
                            <Form.Item name={['JobMtl', 'issueComplete']} valuePropName="checked">
                              <Checkbox>发料完成</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobMtl', 'direct']} valuePropName="checked">
                              <Checkbox>直接生产</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobMtl', 'buyIt']} valuePropName="checked">
                              <Checkbox>直接采购</Checkbox>
                            </Form.Item>
                            <Form.Item
                              name={['JobMtl', 'rcvInspectionReq']}
                              valuePropName="checked"
                            >
                              <Checkbox>需要检验</Checkbox>
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                      </Col>
                      <Col span={12}></Col>
                    </Row>
                  </TabPane>
                  <TabPane tab="半成品" key="3">
                    <Row>
                      <Col span={12}>
                        <Form.Item name={['JobAsmbl', 'id']} hidden>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobAsmbl', 'jobNum']} hidden>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobAsmbl', 'parent']} hidden>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobAsmbl', 'assemblySeq']} label="半成品号">
                          <InputNumber min={1} step={1} />
                        </Form.Item>
                        <Form.Item label="物料编码">
                          <Input.Group compact>
                            <PartSelect
                              name={['JobAsmbl', 'partNum']}
                              noStyle
                              width={200}
                              required={true}
                              placeholder="物料编码"
                              setCurrent={this.setCurrent3}
                              pType="M"
                            />
                            <Form.Item noStyle name={['JobAsmbl', 'revisionNum']}>
                              {selectRev2}
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item name={['JobAsmbl', 'partDescription']} label="描述">
                          <Input disabled />
                        </Form.Item>
                        <Form.Item style={{ marginBottom: 0 }} label="相关工序">
                          <Input.Group compact>
                            <Form.Item name={['JobAsmbl', 'relatedOperation']}>
                              <Input placeholder="10" />
                            </Form.Item>
                            <Form.Item>
                              <Input placeholder="工序描述" />
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item label="数量/父项" style={{ marginBottom: 0 }}>
                          <Input.Group compact>
                            <Form.Item
                              noStyle
                              name={['JobAsmbl', 'qtyPer']}
                              rules={[{ required: true, message: '需求数量必填' }]}
                            >
                              <InputNumber min={1} style={{ width: 120, marginRight: 10 }} />
                            </Form.Item>
                            <Form.Item name={['JobAsmbl', 'fixedQty']} valuePropName="checked">
                              <Checkbox>固定数量</Checkbox>
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item label="需求数量">
                          <Input.Group compact>
                            <Form.Item
                              noStyle
                              name={['JobAsmbl', 'requiredQty']}
                              rules={[{ required: true, message: '需求数量必填' }]}
                            >
                              <InputNumber min={1} style={{ width: 120 }} />
                            </Form.Item>
                            <Form.Item
                              noStyle
                              name={['JobAsmbl', 'ium']}
                              rules={[{ required: true, message: '单位必填' }]}
                            >
                              <Input disabled style={{ width: 70 }} placeholder="单位" />
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item
                          name={['JobAsmbl', 'direct']}
                          valuePropName="checked"
                          wrapperCol={{ offset: 5 }}
                        >
                          <Checkbox>直接生产</Checkbox>
                        </Form.Item>
                      </Col>
                      <Col span={12}></Col>
                    </Row>
                  </TabPane>
                  <TabPane tab="工序" key="4">
                    <Row>
                      <Col span={12}>
                        <Form.Item name={['JobOper', 'id']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobOper', 'jobNum']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobOper', 'partDescription']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobOper', 'partNum']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobOper', 'revisionNum']} hidden={true}>
                          <Input />
                        </Form.Item>
                        <Form.Item name={['JobOper', 'assemblySeq']} label="半成品号">
                          <InputNumber min={1} step={1} />
                        </Form.Item>
                        <Form.Item name={['JobOper', 'oprSeq']} label="序号">
                          <InputNumber min={1} step={1} disabled />
                        </Form.Item>
                        <Form.Item label="生产标准">
                          <Input.Group compact>
                            <Form.Item
                              noStyle
                              name={['JobOper', 'prodStandard']}
                              rules={[{ required: true, message: '请输入生产标准' }]}
                            >
                              <Input style={{ width: 200 }} />
                            </Form.Item>
                            <Form.Item noStyle name={['JobOper', 'stdFormat']}>
                              <Select placeholder="小时/件" style={{ width: 90 }}>
                                <Select.Option value="HP">小时/件</Select.Option>
                                <Select.Option value="MP">分钟/件</Select.Option>
                                <Select.Option value="PM">件/分钟</Select.Option>
                                <Select.Option value="OH">件/小时</Select.Option>
                              </Select>
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <OpMasterSelect
                          width={200}
                          labelInValue
                          required={false}
                          showSearch={false}
                          name={['JobOper', 'opCode']}
                          label="工序"
                        />
                        <Form.Item style={{ marginBottom: 0 }} wrapperCol={{ offset: 5 }}>
                          <Input.Group compact>
                            <Form.Item name={['JobOper', 'subContract']} valuePropName="checked">
                              <Checkbox>外包</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobOper', 'finalOpr']} valuePropName="checked">
                              <Checkbox>最后工序</Checkbox>
                            </Form.Item>
                            <Form.Item name={['JobOper', 'autoReceive']} valuePropName="checked">
                              <Checkbox>自动收货</Checkbox>
                            </Form.Item>
                          </Input.Group>
                        </Form.Item>
                        <Form.Item
                          name={['JobOper', 'schedRelation']}
                          label="排程方式"
                          rules={[{ required: true, message: '请选择排程方式' }]}
                        >
                          <Radio.Group>
                            <Radio value="SS">开始-到-开始</Radio>
                            <Radio value="FS">结束-到-开始</Radio>
                            <Radio value="FF">结束-到-结束</Radio>
                          </Radio.Group>
                        </Form.Item>
                      </Col>
                      <Col span={12}>
                        <ResourceGrpSelect
                          width={200}
                          required={true}
                          showSearch={false}
                          name={['JobOper', 'resourceGrpID']}
                          label="资源群组"
                        />
                        <ResourceSelect
                          width={200}
                          required={true}
                          showSearch={false}
                          name={['JobOper', 'resourceID']}
                          label="资源"
                        />
                        <Form.Item label="工序备注" name={['JobOper', 'commentText']}>
                          <Input.TextArea rows={5} />
                        </Form.Item>
                      </Col>
                    </Row>
                  </TabPane>
                </Tabs>
              </Card>
            </Col>
          </Row>
        </Form>
      </PageHeaderWrapper>
    );
  }
}
export default connect(({ Abp }: API.IConnectState) => ({
  response: Abp.response,
  currentUser: Abp.currentUser,
}))(ViewPage);
